using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Designers
{
	/// <summary>
	/// System.EventArgs is the base class for classes containing event data.
	/// </summary>
	public class FrameDesignerEventArgs : EventArgs
	{
        /// <summary>
        /// Gets or sets the parent.
        /// </summary>
        /// <value>The parent.</value>
        public Control Parent { get; set; }

        /// <summary>
        /// Gets or sets the new component.
        /// </summary>
        /// <value>The new component.</value>
        public IComponent NewComponent { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="FrameDesignerEventArgs"/> class.
        /// </summary>
        /// <param name="newComponent">The new component.</param>
        /// <param name="parent">The parent.</param>
		public FrameDesignerEventArgs(IComponent newComponent, Control parent)
		{
            if (newComponent == null)
                throw new ArgumentNullException("newComponent");

            NewComponent = newComponent;
			Parent = parent;
		}

        /// <summary>
        /// Initializes a new instance of the <see cref="FrameDesignerEventArgs"/> class.
        /// </summary>
        /// <param name="newComponent">The new component.</param>
        public FrameDesignerEventArgs(IComponent newComponent)
		{
            if (newComponent == null)
                throw new ArgumentNullException("newComponent");

            NewComponent = newComponent;
            
            if(newComponent is Control)
                Parent = ((Control)newComponent).Parent;
		}
	}
}